package edu.xkd.slice;

import edu.xkd.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.Text;

public class MainAbilitySlice extends AbilitySlice {

    Text text_01 = null;
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
    //获取组件
        text_01= (Text) this.findComponentById(ResourceTable.Id_text_info);
        Button button_login = (Button) this.findComponentById(ResourceTable.Id_button_login);
        Button button_register = (Button) this.findComponentById(ResourceTable.Id_button_register);

        button_login.setClickedListener(this::clickedListenerButton01);
        button_register.setClickedListener(this::clickedListenerButton02);
    }

    private void clickedListenerButton01(Component component) {
        text_01.setText("登录按钮单击！");
    }
    private void clickedListenerButton02(Component component) {
        text_01.setText("注册按钮单击！");
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
